/*****************************************************************************/
/*                                                                           */
/*    Domino Operation System Kernel Module                                  */
/*                                                                           */
/*    Copyright (C) 2005 Laszlo Arvai                                        */
/*                                                                           */
/*    ------------------------------------------------------------------     */
/*    krnlRealTimeClock - Real Time Clock Functions                          */
/*****************************************************************************/

///////////////////////////////////////////////////////////////////////////////
// Includes
#include "krnlRealTimeClock.h"
#include "drvRealTimeClock.h"
#include "krnlMessages.h"

///////////////////////////////////////////////////////////////////////////////
// Initialize real time clock
void krnlInitRealTimeClock(void)
{
  drvInitRealTimeClock();
}


///////////////////////////////////////////////////////////////////////////////
// Convert message to datetime
void krnlConvertMessageToDateTime( krnlMessage* in_message, krnlDateTime *out_datetime )
{
  // check perameters
  if( in_message == NULL || out_datetime == NULL || in_message->Id != msgREAL_TIME_MESSAGE )
    return;

  // convert message to datetime
  // copy time
  out_datetime->Hour    = in_message->Data[0];
  out_datetime->Minute  = in_message->Data[1];
  out_datetime->Second  = in_message->Data[2];

  // copy date
  out_datetime->Year    = in_message->Data[3] + ( in_message->Data[4] << 8 );
  out_datetime->Month   = in_message->Data[5];
  out_datetime->Day     = in_message->Data[6];

  // day of week
  out_datetime->DayOfWeek = in_message->Data[7];
}
